package edu.polsl.bio.str.frontend.server;

import edu.polsl.bio.str.frontend.client.dotplot.DotPlotService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;

/**
 * //todo class description
 * <p/>
 * Created on: Jul 31, 2011 8:05:01 PM <br/>
 * <a href="http://www.polsl.pl">www.polsl.pl</a>
 *
 * @author lukasz.olczak@polsl.pl
 */
@Controller("dotPlot")
public class DotPlotServiceImpl extends BaseServiceServlet implements DotPlotService {
  /**
   * slf4j Logger.
   */
  private static final Logger log = LoggerFactory.getLogger(DotPlotServiceImpl.class.getName());

  public List<double[][]> getDotPlot() throws Exception {
    log.debug("Returning dot plot");
    int width = 1000;
    int height = 1000;
    double[][] forwardTab = new double[width][height];
    double[][] backward = new double[width][height];
    Random random = new Random();
    for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
        forwardTab[x][y] = random.nextDouble();
        backward[x][y] = random.nextDouble();
      }
    }
    List<double[][]> results = new LinkedList();
    results.add(forwardTab);
    results.add(backward);
    return results;
  }
}
